home *** CD-ROM | disk | FTP | other *** search
- Unit OO123;
-
- (*
- Over the last year we've lurked behind the scenes here, enjoying
- the fruits of your labours.
-
- It seemed time to give something back, so here's a unit that will
- enable you to create Lotus 1-2-3 V2.x compatible models quickly
- and easily via OOP. We use the TurboPower Object Professional
- date routines but any julian date routine will work if you change
- TDateCell.Init. If you don't have any date routines, just UNDEF
- USEDATES.
-
- Here's a simple test program:-
-
- Program Test;
-
- {$N+,E+}
-
- Uses Objects, OO123;
-
- Var P123 : PModel;
- PD : PDateCell;
- PT : PTextCell;
- PN : PNumericCell;
- Y : Word;
- Begin
- P123:=New(PModel, Init('TEST.WK1'));
- If P123<>NIL then with P123^ do
- Begin
- PT:=AddTextCell('..Date..');
- AddTextCell('Refce')^.JustRight;
- AddTextCell('Amount')^.JustRight;
- AddTextCell('Narration');
- NewRow;
- NewRow;
- For Y:=1 to 100 do
- Begin
- PD:=AddDateCell('1/03/93');
- PN:=AddNumericCell(Y);
- PN:=AddNumericCell(100.00);
- PT:=AddTextCell('This is a narration');
- PT:=AddTextCell('');
- If PT^.Value<>NIL then DisposeStr(PT^.Value);
- PT^.Value:=NewStr('This is cell '+PT^.Reference);
- NewRow;
- end;
- SetColumnWidth(3,30);
- SetColumnWidth(4,30);
- Save;
- Dispose(P123, Done);
- end;
- end.
-
- PS: If you're wondering why there isn't a type TExpressionCell it's
- because I've never figured out expression encoding. There's a simple
- workaround: just prefix each expression with a special character
- (say '|'), then run the following Lotus 1-2-3 macro:-
-
- ------------------------------------------------------------------------
-
- \A {indicate Formula Conversion..}{paneloff}{windowsoff}
- /rncHERE~{bs}~
- {home}
- /rncWORKAREA~{bs}.{end}{home}~
- {for WIDTH,1,@cols(WORKAREA),1,LOOP1}
- {goto}HERE~
- /rndWORKAREA~/rndHERE~
- {indicate}
-
- LOOP1 {for HEIGHT,1,@rows(WORKAREA),1,LOOP2}
- {right}{up HEIGHT-1}
-
- LOOP2 {if @cellpointer("type")<>"l"}{down}{return}
- {if @length(@cellpointer("contents"))=0}/re~/rfr~{down}{return}
- {if @left(@cellpointer("contents"),1)<>"|"}{down}{return}
- {edit}{home}{del}{del}~
- {down}
-
- WIDTH 8
- HEIGHT 25
-
- ERRCHECK @code(@cellpointer)
-
- ------------------------------------------------------------------------
-
- If you know how to create a TExpressionCell the hard way, and you
- wouldn't mind sharing your knowledge, then please feel free to e-mail
- us.
-
- Enjoy...
-
- Steve Agnew
- CIS 70032,2240
-
- *)
-
- {$D-,S-,R-,L-,N+,E+}
-
- {$DEFINE USEDATES}
-
- INTERFACE
-
- Uses Objects, DOS
- {$IFDEF USEDATES} , OpDate {$ENDIF}
- ;
-
- CONST
- fProtected = $80;
- fFixed = $00;
- fScientific = $10;
- fCurrency = $20;
- fPercent = $30;
- fComma = $40;
- fSpecial = $70;
- fGeneral = $01;
- fDMY = $02;
- fDM = $03;
- fMY = $04;
- fText = $05;
-
- TYPE
- PCell = ^TCell;
- TCell = Object(TObject)
- CellType : Word;
- CellLength : Word;
- CellFormat : Byte;
- CellColumn : Word;
- CellRow : Word;
- Constructor Init(AType, AColumn, ARow : Word);
- Procedure SetFormat(AFormat : Byte);
- Procedure Write(Var S : TBufStream); VIRTUAL;
- Function Reference: String;
- end;
-
- { -------------------------------------------------------------------- }
-
- PNumericCell = ^TNumericCell;
- TNumericCell = Object(TCell)
- Value : Double;
- Constructor Init(AColumn, ARow : Word; AValue : Double);
- Procedure Write(Var S : TBufStream); VIRTUAL;
- end;
-
- { -------------------------------------------------------------------- }
-
- PCurrencyCell = ^TCurrencyCell;
- TCurrencyCell = Object(TCell)
- Value : Double;
- Constructor Init(AColumn, ARow : Word; AValue : Double);
- Procedure Write(Var S : TBufStream); VIRTUAL;
- end;
-
- {$IFDEF USEDATES}
- { -------------------------------------------------------------------- }
- PDateCell = ^TDateCell;
- TDateCell = Object(TCell)
- Value : Double;
- Constructor Init(AColumn, ARow : Word; AValue : String);
- Procedure Write(Var S : TBufStream); VIRTUAL;
- end;
- {$ENDIF}
- { -------------------------------------------------------------------- }
-
- PTextCell = ^TTextCell;
- TTextCell = Object(TCell)
- Just : Char;
- Value : PString;
- Constructor Init(AColumn, ARow : Word; AValue : String);
- Procedure Write(Var S : TBufStream); VIRTUAL;
- Procedure JustLeft;
- Procedure JustCentre;
- Procedure JustRight;
- Destructor Done; VIRTUAL;
- end;
-
- { -------------------------------------------------------------------- }
-
- PCellCollection = ^TCellCollection;
- TCellCollection = Object(TSortedCollection)
- function Compare(Key1, Key2: Pointer): Integer; VIRTUAL;
- function FindCell(Col, Row : Word): Pointer;
- Procedure Write(Var S: TBufStream); VIRTUAL;
- end;
-
- { -------------------------------------------------------------------- }
-
- ColumnInfo = Record
- First : Word;
- Last : Word;
- Width : Byte;
- end;
-
- PModel = ^TModel;
- TModel = Object(TObject)
- FileName : PathStr;
- Cells : PCellCollection;
- PRIVATE
- MaxRows : Word;
- MaxCols : Word;
- Row : Word;
- Col : Word;
- ColHdr : Array[0..255] of ColumnInfo;
- PUBLIC
- Constructor Init(AFileName : PathStr);
- Procedure Save;
- Procedure NewRow;
- Procedure NewColumn;
- Function AddNumericCell (AValue : Double): PNumericCell;
- Function AddCurrencyCell (AValue : Double): PCurrencyCell;
- {$IFDEF USEDATES}
- Function AddDateCell (AValue : String): PDateCell;
- {$ENDIF}
- Function AddTextCell (AValue : String): PTextCell;
- Procedure SetColumnWidth (Column,Width: Word);
- Function FindCell(AColumn, ARow : Word): Pointer;
- Destructor Done; VIRTUAL;
- end;
-
- { -------------------------------------------------------------------- }
-
-
- IMPLEMENTATION
-
- Function NumToStr(N: LongInt): String;
- Var S : String;
- Begin
- Str(N,S);
- NumToStr:=S;
- end;
-
- { =============================[ TCELL ]============================ }
-
- Constructor TCell.Init(AType, AColumn, ARow : Word);
-
- Begin
- If not Inherited Init then FAIL;
- CellType := AType;
- CellColumn := AColumn;
- CellRow := ARow;
- CellFormat := $71;
- end;
-
- { -------------------------------------------------------------------- }
-
- Procedure TCell.SetFormat(AFormat : Byte);
- Begin
- CellFormat := AFormat;
- end;
-
- { -------------------------------------------------------------------- }
-
- Procedure TCell.Write(Var S : TBufStream);
- Begin
- Abstract;
- end;
-
- { -------------------------------------------------------------------- }
-
- Function TCell.Reference: String;
-
- Function MakeRef( x1,y1 : Integer): String;
-
- Var
- S : String[10];
- begin
- S:='';
- If x1>26 then
- begin
- S:=S+Chr(((x1-1) div 26)+64);
- S:=S+Chr(((x1-1) mod 26)+65);
- If y1>0 then S:=S+NumToStr(y1);
- end
- else
- begin
- If x1>0 then S:=S+Chr(x1+64);
- If y1>0 then S:=S+NumToStr(y1);
- end;
- MakeRef:=S;
- end;
-
- Begin
- Reference:=MakeRef(CellColumn+1, CellRow+1);
- end;
-
- { ==========================[ TNUMERICCELL ]========================= }
-
- Constructor TNumericCell.Init(AColumn, ARow : Word; AValue : Double);
-
- Begin
- If not Inherited Init($0E,AColumn,ARow) then FAIL;
- Value:=AValue;
- end;
-
- { -------------------------------------------------------------------- }
-
- Procedure TNumericCell.Write (Var S : TBufStream);
-
- Begin
- CellLength:=13;
- S.Write( CellType , Sizeof( CellType ));
- S.Write( CellLength , Sizeof( CellLength ));
- S.Write( CellFormat , Sizeof( CellFormat ));
- S.Write( CellColumn , Sizeof( CellColumn ));
- S.Write( CellRow , Sizeof( CellRow ));
- S.Write( Value , Sizeof( Value ));
- end;
-
- { ==========================[ TCURRENCYCELL ]========================= }
-
- Constructor TCurrencyCell.Init(AColumn, ARow : Word; AValue : Double);
-
- Begin
- If not Inherited Init($0E,AColumn,ARow) then FAIL;
- Value:=AValue;
- CellFormat:=$22;
- end;
-
- { -------------------------------------------------------------------- }
-
- Procedure TCurrencyCell.Write (Var S : TBufStream);
-
- Begin
- CellLength:=13;
- S.Write( CellType , Sizeof( CellType ));
- S.Write( CellLength , Sizeof( CellLength ));
- S.Write( CellFormat , Sizeof( CellFormat ));
- S.Write( CellColumn , Sizeof( CellColumn ));
- S.Write( CellRow , Sizeof( CellRow ));
- S.Write( Value , Sizeof( Value ));
- end;
-
- {$IFDEF USEDATES}
-
- { ==========================[ TDATECELL ]========================= }
-
- Constructor TDateCell.Init(AColumn, ARow : Word; AValue : String);
-
- Var ADate : Double;
- NewDate : Date;
- RefDate : Date;
- Begin
- If not Inherited Init($0E,AColumn,ARow) then FAIL;
- RefDate := DMYToDate(1,3,93);
- NewDate := DateStringtoDate('DD/MM/YY',AValue);
- Value := 34029.0 { Lotus Representation of 01-03-93 }
- + (NewDate - RefDate);
- CellFormat:=$F2;
- end;
-
- { -------------------------------------------------------------------- }
-
- Procedure TDateCell.Write (Var S : TBufStream);
-
- Begin
- CellLength:=13;
- S.Write( CellType , Sizeof( CellType ));
- S.Write( CellLength , Sizeof( CellLength ));
- S.Write( CellFormat , Sizeof( CellFormat ));
- S.Write( CellColumn , Sizeof( CellColumn ));
- S.Write( CellRow , Sizeof( CellRow ));
- S.Write( Value , Sizeof( Value ));
- end;
-
- {$ENDIF}
- { ==========================[ TALPHACELL ]========================= }
-
- Constructor TTextCell.Init(AColumn, ARow : Word; AValue : String);
-
- Begin
- If not Inherited Init($0F,AColumn,ARow) then FAIL;
- Value:=NewStr(AValue);
- Just:=#$27;
- end;
-
- { -------------------------------------------------------------------- }
-
- Procedure TTextCell.JustLeft;
-
- Begin Just:=#$27; end; { ' }
-
- { -------------------------------------------------------------------- }
-
- Procedure TTextCell.JustCentre;
-
- Begin Just:='^'; end;
-
- { -------------------------------------------------------------------- }
-
- Procedure TTextCell.JustRight;
-
- Begin Just:='"'; end;
-
- { -------------------------------------------------------------------- }
-
- Destructor TTextCell.Done;
-
- Begin
- If Value<>NIL then DisposeStr(Value);
- Value:=NIL;
- Inherited Done;
- end;
-
- { -------------------------------------------------------------------- }
-
- Procedure TTextCell.Write (Var S : TBufStream);
-
- Var V : String;
- E : Byte;
-
- Begin
- V:=''; If Value<>NIL then V:=Value^;
- CellLength:=7+Length(V);
- S.Write( CellType , Sizeof( CellType ));
- S.Write( CellLength , Sizeof( CellLength ));
- S.Write( CellFormat , Sizeof( CellFormat ));
- S.Write( CellColumn , Sizeof( CellColumn ));
- S.Write( CellRow , Sizeof( CellRow ));
- S.Write( Just , Sizeof( Just ));
- If Length(V)>0 then S.Write( V[1], Length(V) );
- E:=0;
- S.Write( E , Sizeof( E ));
- end;
-
- { ==========================[ TCELLCOLLECTION ]========================= }
-
- function TCellCollection.Compare(Key1, Key2: Pointer): Integer;
-
- Var C1 : PCell absolute Key1;
- C2 : PCell absolute Key2;
- Begin
- if C1^.CellRow < C2^.CellRow then Begin Compare := -1; exit; end;
- if C1^.CellRow > C2^.CellRow then Begin Compare := 1; exit; end;
- { Same Row }
- if C1^.CellColumn < C2^.CellColumn then Begin Compare := -1; exit; end;
- if C1^.CellColumn > C2^.CellColumn then Begin Compare := 1; exit; end;
- Compare:=0;
- end;
-
- { -------------------------------------------------------------------- }
-
- function TCellCollection.FindCell(Col, Row: Word): Pointer;
-
- Function Matches(P : PCell): Boolean; FAR;
-
- Begin
- Matches:=(P^.CellColumn=Col) AND (P^.CellRow = Row);
- end;
-
- Begin
- FindCell:=FirstThat(@Matches);
- end;
-
- { -------------------------------------------------------------------- }
-
- Procedure TCellCollection.Write(Var S: TBufStream);
-
- Function WriteCell(P : PCell): Boolean; FAR;
-
- Begin
- P^.Write(S);
- end;
-
- Begin
- ForEach(@WriteCell);
- end;
-
- { ==========================[ TMODEL ]========================= }
-
- Constructor TModel.Init(AFileName : PathStr);
-
- Begin
- If not Inherited Init then FAIL;
- FileName := AFileName;
- Cells:=New(PCellCollection, Init(100,50));
- If Cells=NIL then FAIL;
- end;
-
- { ------------------------------------------------------------------ }
-
- Procedure TModel.NewRow;
-
- Begin
- Inc(Row);
- Col:=0;
- end;
-
- { ------------------------------------------------------------------ }
-
- Procedure TModel.NewColumn;
-
- Begin
- Inc(Col);
- end;
-
- { ------------------------------------------------------------------ }
-
- Function TModel.AddNumericCell(AValue : Double): PNumericCell;
-
- Var P : PNumericCell;
-
- Begin
- P:=New(PNumericCell, Init(Col, Row, AValue));
- If P<>NIL then
- Begin
- Cells^.Insert(P);
- If ColHdr[Col].Width<15 then ColHdr[Col].Width:=15;
- If (Row < ColHdr[Col].First) then ColHdr[Col].First:=Row;
- If (Row > ColHdr[Col].Last ) then ColHdr[Col].Last :=Row;
- If Row>MaxRows then MaxRows:=Row;
- If Col>MaxCols then MaxCols:=Col;
- Inc(Col);
- end;
- AddNumericCell:=P;
- end;
-
- { ------------------------------------------------------------------ }
-
- Function TModel.AddCurrencyCell(AValue : Double): PCurrencyCell;
-
- Var P : PCurrencyCell;
-
- Begin
- P:=New(PCurrencyCell, Init(Col, Row, AValue));
- If P<>NIL then
- Begin
- Cells^.Insert(P);
- If ColHdr[Col].Width<15 then ColHdr[Col].Width:=15;
- If (Row < ColHdr[Col].First) then ColHdr[Col].First:=Row;
- If (Row > ColHdr[Col].Last ) then ColHdr[Col].Last :=Row;
- If Row>MaxRows then MaxRows:=Row;
- If Col>MaxCols then MaxCols:=Col;
- Inc(Col);
- end;
- AddCurrencyCell:=P;
- end;
-
- { ------------------------------------------------------------------ }
- {$IFDEF USEDATES}
- Function TModel.AddDateCell(AValue : String): PDateCell;
-
- Var P : PDateCell;
-
- Begin
- P:=New(PDateCell, Init(Col, Row, AValue));
- If P<>NIL then
- Begin
- Cells^.Insert(P);
- If ColHdr[Col].Width<10 then ColHdr[Col].Width:=10;
- If (Row < ColHdr[Col].First) then ColHdr[Col].First:=Row;
- If (Row > ColHdr[Col].Last ) then ColHdr[Col].Last :=Row;
- If Row>MaxRows then MaxRows:=Row;
- If Col>MaxCols then MaxCols:=Col;
- Inc(Col);
- end;
- AddDateCell:=P;
- end;
- {$ENDIF}
- { ------------------------------------------------------------------ }
-
- Function TModel.AddTextCell(AValue : String): PTextCell;
-
- Var P : PTextCell;
-
- Begin
- P:=New(PTextCell, Init(Col, Row, AValue));
- If P<>NIL then
- Begin
- Cells^.Insert(P);
- If ColHdr[Col].Width<(Length(AValue)+2) then ColHdr[Col].Width:=Length(AValue)+2;
- If (Row < ColHdr[Col].First) then ColHdr[Col].First:=Row;
- If (Row > ColHdr[Col].Last ) then ColHdr[Col].Last :=Row;
- If Row>MaxRows then MaxRows:=Row;
- If Col>MaxCols then MaxCols:=Col;
- Inc(Col);
- end;
- AddTextCell:=P;
- end;
-
- { ------------------------------------------------------------------ }
-
- Procedure TModel.SetColumnWidth(Column,Width: Word);
-
- Begin
- ColHdr[Column].Width:=Width;
- end;
-
- { ------------------------------------------------------------------ }
-
- Function TModel.FindCell(AColumn, ARow : Word): Pointer;
-
- Begin
- FindCell:=Cells^.FindCell(AColumn, ARow);
- end;
-
- { ------------------------------------------------------------------ }
-
- Procedure TModel.Save;
-
- TYPE
- b1 = Byte;
- b2 = Array[1..2] of Byte;
- b4 = Array[1..4] of Byte;
- b5 = Array[1..5] of Byte;
- b6 = Array[1..6] of Byte;
- b7 = Array[1..7] of Byte;
- b8 = Array[1..8] of Byte;
- b12 = Array[1..12] of Byte;
- b14 = Array[1..14] of Byte;
- b17 = Array[1..17] of Byte;
- b20 = Array[1..20] of Byte;
- b29 = Array[1..29] of Byte;
- b36 = Array[1..36] of Byte;
- b44 = Array[1..44] of Byte;
-
- CONST
- _BOF : b6 = ($00, $00, $02, $00, $06, $04); { Lotus 1-2-3 Rel 2 }
- _EOF : b4 = ($01, $00, $00, $00); { End of File Marker }
- _CALCMODE : b5 = ($02, $00, $01, $00, $00); { Manual Calculation }
- _CALCCOUNT : b5 = ($2F, $00, $01, $00, $01); { Calculation Count }
- _CALCORDER : b5 = ($03, $00, $01, $00, $00); { Natural Order }
- _SPLIT : b5 = ($04, $00, $01, $00, $00); { Window not Split }
- _SYNCH : b5 = ($05, $00, $01, $00, $00); { Window not Synchronised }
-
- _RANGE : b8 = ($06, $00, $08, $00, $00, $00, $00, $00);
-
- __WINDOW1 : b36 = ($07, $00, $20, $00, { Window 1 Description }
- $00, $00, { Current Cursor Column }
- $00, $00, { Current Cursor Row }
- $00, { Cell Format Byte }
- $00, { Unused }
- $00, $00, { Column Width }
- $00, $00, { Number of Columns on Screen }
- $00, $00, { Number of Rows on Screen }
- $00, $00, { Leftmost Column }
- $00, $00, { Top Row }
- $00, $00, { Number of Title Columns }
- $00, $00, { Number of Title Rows }
- $00, $00, { Left Title Column }
- $00, $00, { Left Title Row }
- $00, $00, { Border Width Column }
- $00, $00, { Border Width Row }
- $00, $00, { Window Width }
- $00, $00 ); { Unused }
-
- _COLW1 : b4 = ($08, $00, $03, $00 ); { Set Column Width }
-
- _HIDVEC1 : b36 = ($64, $00, $20, $00, { Hidden Columns }
- $00, $00, $00, $00,
- $00, $00, $00, $00,
- $00, $00, $00, $00,
- $00, $00, $00, $00,
- $00, $00, $00, $00,
- $00, $00, $00, $00,
- $00, $00, $00, $00,
- $00, $00, $00, $00 );
-
- _TABLE : b29 = ($18, $00, $19, $00, { Table Range }
- $00, $FF, $FF, $FF,
- $FF, $FF, $FF, $FF,
- $FF, $FF, $FF, $FF,
- $FF, $FF, $FF, $FF,
- $FF, $FF, $FF, $FF,
- $FF, $FF, $FF, $FF,
- $FF );
-
- _QRANGE : b29 = ($19, $00, $19, $00, { Query Range }
- $FF, $FF, $FF, $FF,
- $FF, $FF, $FF, $FF,
- $FF, $FF, $FF, $FF,
- $FF, $FF, $FF, $FF,
- $FF, $FF, $FF, $FF,
- $FF, $FF, $FF, $FF,
- $00 );
-
- _PRANGE : b12= ($1A, $00, $08, $00, { Print Range }
- $FF, $FF, { Start Column }
- $00, $00, { Start Row }
- $FF, $FF, { End Column }
- $00, $00 ); { End Row }
-
- _UNFORMATTED : b5 = ($30, $00, $01, $00, $00); { Unformatted Printing }
-
- _FRANGE : b12 = ($1C, $00, $08, $00, { Fill Range }
- $FF, $FF, { Start Column }
- $FF, $FF, { Start Row }
- $FF, $FF, { End Column }
- $FF, $FF ); { End Row }
-
- _SRANGE : b12 = ($1B, $00, $08, $00, { Sort Range }
- $00, $00, { Start Column }
- $FF, $FF, { Start Row }
- $00, $00, { End Column }
- $00, $00 ); { End Row }
-
- _RRANGE : b29 = ($19, $00, $19, $00, { Query Range }
- $FF, $FF, $FF, $FF,
- $FF, $FF, $FF, $FF,
- $FF, $FF, $FF, $FF,
- $FF, $FF, $FF, $FF,
- $FF, $FF, $FF, $FF,
- $FF, $FF, $FF, $FF,
- $00 );
-
- _MATRIXRANGE : b44 = ($69, $00, $28, $00, { Matrix Range }
- $FF, $FF, $FF, $FF,
- $FF, $FF, $FF, $FF,
- $FF, $FF, $FF, $FF,
- $FF, $FF, $FF, $FF,
- $FF, $FF, $FF, $FF,
- $FF, $FF, $FF, $FF,
- $FF, $FF, $FF, $FF,
- $FF, $FF, $FF, $FF,
- $FF, $FF, $FF, $FF,
- $FF, $FF, $FF, $FF );
-
- _HRANGE : b20 = ($20, $00, $10, $00, { Distribution Range }
- $FF, $FF, { Values Range Start Column }
- $FF, $FF, { Values Range Start Row }
- $FF, $FF, { Values Range End Column }
- $FF, $FF, { Values Range End Row }
- $FF, $FF, { Bin Range Start Column }
- $FF, $FF, { Bin Range Start Row }
- $FF, $FF, { Bin Range Start Column }
- $FF, $FF ); { Bin Range Start Row }
-
- _GPROTECT : b5 = ($24, $00, $01, $00, $00); { Global Protection }
-
- _MARGINS : b14 = ($28, $00, $0A, $00, { Margin Settings }
- $0A, $00, { Left Margin }
- $49, $00, { Right Margin }
- $42, $00, { Page Length }
- $06, $00, { Top Margin }
- $06, $00 ); { Bottom Margin }
-
- _LABELFMT : b5 = ($29, $00, $01, $00, $27); { Label Alignment }
-
- _TITLES : b20 = ($2A, $00, $10, $00, { Print Borders }
- $FF, $FF, { Row Border Start Column }
- $00, $00, { Row Border Start Row }
- $FF, $FF, { Row Border End Column }
- $00, $00, { Row Border End Row }
- $FF, $FF, { Column Border Start Column }
- $00, $00, { Column Border Start Row }
- $FF, $FF, { Column Border Start Column }
- $00, $00 ); { Column Border Start Row }
-
- Var S : TBufStream; B,X : Byte; L,W : Word;
-
- Begin { TModel.Save }
- S.Init(FileName, stCreate, 1024);
- If S.Status=stOK then
- Begin
- S.Write( _BOF , Sizeof( _BOF ));
- S.Write( _RANGE , Sizeof( _RANGE ));
- S.Write( MaxCols , Sizeof( MaxCols ));
- S.Write( MaxRows , Sizeof( MaxRows ));
-
- L:=0;
- For x:=0 to MaxCols do
- if (ColHdr[x].Last<>0) OR
- (ColHdr[x].Width<>0)
- then l:=l+6;
-
- X:=$96; S.Write( X, Sizeof( X ));
- X:=$00; S.Write( X, Sizeof( X ));
- S.Write( L, Sizeof( L ));
- For W:=0 to MaxCols do
- if (ColHdr[W].Last<>0) OR
- (ColHdr[W].Width<>0) Then
- Begin
- S.Write( W, Sizeof( W ));
- S.Write( ColHdr[W].First , Sizeof( Word ));
- S.Write( ColHdr[W].Last , Sizeof( Word ));
- End;
-
- S.Write( _CALCCOUNT , Sizeof( _CALCCOUNT ));
- S.Write( _CALCMODE , Sizeof( _CALCMODE ));
- S.Write( _CALCORDER , Sizeof( _CALCORDER ));
- S.Write( _SPLIT , Sizeof( _SPLIT ));
- S.Write( _SYNCH , Sizeof( _SYNCH ));
-
- For W:=0 to MaxCols do
- if (ColHdr[W].Last<>0) OR
- (ColHdr[W].Width<>0) Then
- Begin
- S.Write( _COLW1, Sizeof( _COLW1 ));
- S.Write( W , Sizeof( Word ));
- S.Write( ColHdr[W].Width , Sizeof( Byte ));
- End;
-
- S.Write( _HIDVEC1 ,Sizeof( _HIDVEC1 ));
- S.Write( _TABLE ,Sizeof( _TABLE ));
- S.Write( _QRANGE ,Sizeof( _QRANGE ));
- S.Write( _PRANGE ,Sizeof( _PRANGE ));
- S.Write( _UNFORMATTED ,Sizeof( _UNFORMATTED ));
- S.Write( _FRANGE ,Sizeof( _FRANGE ));
- S.Write( _SRANGE ,Sizeof( _SRANGE ));
- S.Write( _RRANGE ,Sizeof( _RRANGE ));
- S.Write( _MATRIXRANGE ,Sizeof( _MATRIXRANGE ));
- S.Write( _HRANGE ,Sizeof( _HRANGE ));
- S.Write( _GPROTECT ,Sizeof( _GPROTECT ));
- { Footer }
- { Header }
- S.Write( _MARGINS ,Sizeof( _MARGINS ));
- S.Write( _LABELFMT ,Sizeof( _LABELFMT ));
- S.Write( _TITLES ,Sizeof( _TITLES ));
- { Cells }
- Cells^.Write(S);
- S.Write( _EOF ,Sizeof( _EOF ));
- end;
- S.Done;
- end;
-
- { -------------------------------------------------------------------- }
-
- Destructor TModel.Done;
-
- Begin
- If Cells<>NIL then
- Begin
- Cells^.FreeAll;
- Dispose(Cells, Done);
- Cells:=NIL;
- end;
- Inherited Done;
- end;
-
- { -------------------------------------------------------------------- }
-
- END.